<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let obj = {
        name: 'lyx',
        getName(...args) {
          console.log(args);
          console.log(this.name);
        },
      };

      let obj2 = {
        name: 'zzk',
      };

      obj.getName();
      obj.getName.call(obj2, 1, 2); // obj2作为this调用getName()
      obj.getName.apply(obj2, [1, 2]); // 区别于call()，apply()可以传入数组参数
      let func = obj.getName;
      func.bind(obj2)(1, 2);
    </script>
  </body>
</html>
